scale = 3;
interval = 100;

ImgPath = srpath.getDataPath('Set5');
result_path = srpath.getResultPath('CascadeFineTuning2');

ImgCell = srimg.genLHPairs(ImgPath, scale);
ImgCell = ImgCell(:, 2:3);
ImgCell0 = ImgCell;

%%
n_recursive = 3;
% [~, mynet_folder] = fileparts(mynet.result_path);
net.folder = '[VDSR_y-1]-tuning2-[VDSR_y-1]';
mynet_folder = '[[VDSR_y-1]-tuning2-[VDSR_y-1]]-tuning2-[VDSR_y-3]';

net_iters = {
    'VDSR_y-1', 500, 500
    net.folder, 500, 500
    net.folder, 500, 500
    mynet_folder, 100, 500
    };

mynet.name = 'VDSR_y';
net.deploy_file = [mynet.name '_deploy.prototxt'];
mynet.model_prefix = [mynet.name '_iter_'];

psnrList = cell(1, size(net_iters, 1));
for i = 1 : n_recursive
    mynet.model_path = fullfile(result_path, net_iters{i, 1}, 'models');
    mynet.deploy_file = fullfile(result_path, net_iters{i, 1}, net.deploy_file);
    [psnrList{i}, ImgCell] = srimg.analyPSNR2(ImgCell, scale, mynet, [net_iters{i, 2}, interval, net_iters{i, 3}]);
end

for i = n_recursive+1
    mynet.model_path = fullfile(result_path, net_iters{i, 1}, 'models');
    mynet.deploy_file = fullfile(result_path, net_iters{i, 1}, net.deploy_file);
    psnrList{i} = srimg.analyPSNR2(ImgCell, scale, mynet, [net_iters{i, 2}, interval, net_iters{i, 3}]);
end

%%
% myinput.save(psnrList);

%%
meanpsnrList = cellfun(@mean, psnrList, 'uniformoutput', false);
for i = 1 : length(meanpsnrList)
    fprintf('%d  ', net_iters{i, 2} : interval : net_iters{i, 3});
    fprintf('\n')
    fprintf('%.2f ', meanpsnrList{i});
    fprintf('\n======================\n')
end
